#define   _CRT_SECURE_NO_WARNINGS  1
#pragma warning(disable:6031)
#include"address.h"
void Init_List(ST* list)
{
    list->arr = NULL;
    list->Max = list->size = 0;
}
void Expand_list(ST* list)
{
    if (list->Max == list->size)
    {
        int new_Max = list->Max == 0 ? 4 : 2 * list->Max;
        Listsym* test = (Listsym*)realloc(list->arr, new_Max * sizeof(Listsym));
        assert(test);
        list->arr = test;
        list->Max = new_Max;
    }
}
void Printf_list(ST list)
{
    for (int x = 0; x < list.size; x++)
    {
        printf("%d ", list.arr[x]);
    }
    printf("\n");
}
void Add_end_list(ST* list, Listsym n)
{
    assert(list);
    Expand_list(list);
    list->arr[list->size++] = n;
}
void Add_front_list(ST* list, Listsym n)
{
    assert(list);
    Expand_list(list);
    memmove((Listsym*)list->arr + 1, (Listsym*)list->arr, list->size * sizeof(Listsym));
    list->arr[0] = n;
    list->size++;
    /*for (int x = list->size - 1; x >= 0; x--)
    {
        list->arr[x + 1] = list->arr[x];
    }
    list->arr[0] = n;
    list->size++;*/
}
void Dele_end_list(ST* list)
{
    assert(list);
    assert(list->size);
    --list->size;
}
void Dele_front_list(ST* list)
{
    assert(list);
    assert(list->size);
    memmove((Listsym*)list->arr, (Listsym*)list->arr + 1, (list->size - 1) * sizeof(Listsym));
    --list->size;
}
void Destory_List(ST* list)
{
    free(list->arr);
    Init_List(list);
}
